/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c) 2002, GeoVISTA Center
 * Licensed under Simplified BSD License
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 * 
 *
 * @original author: jin Chen 
 * @author: jin Chen 
 * @date: Mar 13, 2008$
 * @version: 1.0
 */
package edu.psu.geovista.common.awt.event;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.EventObject;

public class AbstractGeovistaEventListener implements GeovistaEventListener{
    public void sourceChanged(EventObject e) {
        AbstractGeovistaEventListener.invokeMyMethod(this, e);
    }

    /**
     *  
     * @param thisObj
     * @param e
     */
    public static void invokeMyMethod(Object thisObj, EventObject e) {
        try {
            //Method method = this.getClass().getMethod("sourceChanged", DendrogamOverviewEvent.class);
            Method method = thisObj.getClass().getMethod("sourceChanged", e.getClass()); //find the methond named "sourceChanged", with the parameter in the same type as the given one.
            method.invoke(thisObj,e);
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (InvocationTargetException e1) {
            e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
